import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

/* Layout */
import Layout from '@/layout'
/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
	flag: ['user','index']    control the page roles (you can set multiple roles)
	title: 'title'               the name show in sidebar and breadcrumb (recommend set)
	icon: 'svg-name'             the icon show in the sidebar
	noCache: true                if set true, the page will no be cached(default is false)
	affix: true                  if set true, the tag will affix in the tags-view
	breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
	activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes 无权限路由
 */
export const constantRoutes = [{
	path: '/redirect',
	component: Layout,
	hidden: true,
	children: [{
		path: '/redirect/:path*',
		component: () =>
			import('@/views/redirect/index')
	}]
},
{
	path: '/login',
	component: () =>
		import('@/views/login/index'),
	hidden: true
},
{
	path: '/401',
	component: () =>
		import('@/views/error-page/401'),
	hidden: true
},
{
	path: '/auth-redirect',
	component: () =>
		import('@/views/login/auth-redirect'),
	hidden: true
	},

	{
		path: '/glbView',
		component: () =>
			import('@/views/glbadmin/glbview'),
		name: 'glbView',
		hidden: true
	},
{
	path: '/',
	component: Layout,
	redirect: '/dashboard',
	children: [{
		path: 'dashboard',
		component: () =>
			import('@/views/textbook/index'),
		name: 'dashboard',
		meta: {
			title: '教材管理',
			icon: 'tab',
			noCache: true,
			// flag: 'textbook:textbooks'
		}
	}, {

		path: 'textbookDetails',
		component: () =>
			import('@/views/textbook/details'),
		name: 'textbookDetails',
		hidden: true,
		meta: {
			title: '教材编辑',
			icon: 'tab',
			noCache: true,
		}
	}, {

		path: 'textbookInfo',
		component: () =>
			import('@/views/textbook/info'),
		name: 'textbookInfo',
		hidden: true,
		meta: {
			title: '教材预览',
			icon: 'tab',
			noCache: true,
		}
	}, {

		path: 'textbookTeacher',
		component: () =>
			import('@/views/textbook/teacher'),
		name: 'textbookTeacher',
		hidden: true,
		meta: {
			title: '教材章节分配',
			icon: 'tab',
			noCache: true,
		}
	}]
},
]
/**
 * asyncRoutes 角色路由
 */
export const asyncRoutes = [{
	path: '/system',
	component: Layout,
	redirect: '/system/major',
	meta: {
		title: '系统管理',
		icon: 'list',
		noCache: true,
		flag: 'system:system'
	},
	children: [{
		path: 'teacher',
		component: () =>
			import('@/views/user/user/teacher'),
		name: 'teacher',
		meta: {
			title: '教师管理',
			icon: 'user',
			noCache: true,
			flag: 'user:teacher'
		}
	},
	{
		path: 'student',
		component: () =>
			import('@/views/user/user/student'),
		name: 'student',
		meta: {
			title: '学生管理',
			icon: 'list',
			noCache: true,
			flag: 'user:student'
		}
	},
	{
		path: 'dept',
		component: () =>
			import('@/views/user/dept/index'),
		name: 'dept',
		meta: {
			title: '教研室管理',
			icon: 'documentation',
			noCache: true,
			flag: 'user:dept'
		}
	},
	{
		path: 'organization',
		component: () =>
			import('@/views/user/organization/index'),
		name: 'organization',
		meta: {
			title: '班级管理',
			icon: 'component',
			noCache: true,
			flag: 'user:organization'
		}
	},
	{
		path: 'major',
		component: () =>
			import('@/views/system/major/index'),
		name: 'major',
		meta: {
			title: '专业管理',
			icon: 'documentation',
			noCache: true,
			flag: 'system:major'
		}
	},
	{
		path: 'permission',
		component: () =>
			import('@/views/system/permission/index'),
		name: 'permission',
		meta: {
			title: '权限管理',
			icon: 'component',
			noCache: true,
			flag: 'system:permission'
		}
	},
	{
		path: 'role',
		component: () =>
			import('@/views/system/role/index'),
		name: 'role',
		meta: {
			title: '角色管理',
			icon: 'tab',
			noCache: true,
			flag: 'system:role'
		}
	},
	{
		path: 'logs',
		component: () =>
			import('@/views/system/logs/index'),
		name: 'logs',
		meta: {
			title: '日志管理',
			icon: 'documentation',
			noCache: true,
			flag: 'system:logs'
		}
	},
	{
		path: 'logsmodel',
		component: () =>
			import('@/views/system/logs/model'),
		name: 'logsmodel',
		hidden: true,
		meta: {
			title: '操作日志',
			icon: 'documentation',
			noCache: true,
		}
	},
	]

},
// {
// 	path: '/textbook',
// 	component: Layout,
// 	redirect: '/textbook/textbooks',
// 	meta: {
// 		title: '教材管理',
// 		icon: 'tab',
// 		noCache: true,
// 		flag: 'textbook:textbook'
// 	},
// 	children: [{
// 		path: 'textbooks',
// 		component: () =>
// 			import('@/views/textbook/index'),
// 		name: 'textbooks',
// 		meta: {
// 			title: '教材管理',
// 			icon: 'tab',
// 			noCache: true,
// 			flag: 'textbook:textbooks'
// 		}
// 	}, {

// 		path: 'textbookDetails',
// 		component: () =>
// 			import('@/views/textbook/details'),
// 		name: 'textbookDetails',
// 		hidden: true,
// 		meta: {
// 			title: '教材编辑',
// 			icon: 'tab',
// 			noCache: true,
// 		}
// 	}, {

// 		path: 'textbookInfo',
// 		component: () =>
// 			import('@/views/textbook/info'),
// 		name: 'textbookInfo',
// 		hidden: true,
// 		meta: {
// 			title: '教材预览',
// 			icon: 'tab',
// 			noCache: true,
// 		}
// 	}]

// },
//	{
//		path: '/topic',
//		component: Layout,
//		redirect: '/topic/topics',
//		meta: {
//			title: '试题管理',
//			icon: 'documentation',
//			noCache: true,
//			flag: 'topic:topic'
//		},
//		children: [{
//			path: 'topics',
//			component: () =>
//				import('@/views/topics/index'),
//			name: 'topics',
//			meta: {
//				title: '试题管理',
//				icon: 'list',
//				noCache: true,
//				flag: 'topic:topics'
//			}
//		},{
//			path: 'topicserror',
//			component: () =>
//				import('@/views/topics/error'),
//			name: 'topicserror',
//			hidden: true,
//			meta: {
//				title: '出错试题管理',
//				icon: 'table',
//				noCache: true,
//			}
//		}]
//	},
//	{
//		path: '/vrresource',
//		component: Layout,
//		redirect: '/vrresource/vrresources',
//		meta: {
//			title: '实验管理',
//			icon: 'tab',
//			noCache: true,
//			flag: 'vrresource:vrresource'
//		},
//		children: [{
//			path: 'vrresources',
//			component: () =>
//				import('@/views/vrresource/index'),
//			name: 'vrresources',
//			meta: {
//				title: '实验管理',
//				icon: 'list',
//				noCache: true,
//				flag: 'vrresource:vrresources'
//			}
//		}]
//	},

//	{
//		path: '/vrReportTemplate',
//		component: Layout,
//		redirect: '/vrReportTemplate/vrReportTemplates',
//		meta: {
//			title: '实验模板管理',
//			icon: 'tab',
//			noCache: true,
//			flag: 'vrReportTemplate:vrReportTemplate'
//		},
//		children: [{
//			path: 'vrReportTemplates',
//			component: () =>
//				import('@/views/vrReportTemplate/index'),
//			name: 'vrReportTemplates',
//			meta: {
//				title: '实验模板管理',
//				icon: 'tab',
//				noCache: true,
//				flag: 'vrReportTemplate:vrReportTemplates'
//			}
//		}]
//	},
{
	path: '/vrResourceDetail',
	component: Layout,
	redirect: '/vrResourceDetail/vrResourceDetails',
	meta: {
		title: '实验管理',
		icon: 'component',
		noCache: true,
		flag: 'vrResourceDetail:vrResourceDetail'
	},
	children: [{
		path: 'vrResourceDetails',
		component: () =>
			import('@/views/vrResourceDetail/index'),
		name: 'vrResourceDetails',
		meta: {
			title: '实验管理',
			icon: 'component',
			noCache: true,
			flag: 'vrResourceDetail:vrResourceDetails'
		}
	},
	{
		name: 'vrResourceDetailsjurisdiction',
		path: 'vrResourceDetailsjurisdiction',
		hidden: true,
		component: () =>
			import('@/views/vrResourceDetail/jurisdiction'),
		meta: {
			title: '实验权限管理',
			icon: 'table',
			noCache: true,
			flag: 'vrResourceDetail:jurisdiction'
		}
	},
		//		{
		//
		//			path: 'vrResourceDetailInfo',
		//			component: () =>
		//				import('@/views/vrResourceDetail/detail'),
		//			name: 'vrResourceDetailInfo',
		//			hidden: true,
		//			meta: {
		//				title: '实验资源管理',
		//				icon: 'component',
		//				noCache: true,
		//			}
		//		},
		//		{
		//
		//			path: 'vrResourceInfo',
		//			component: () =>
		//				import('@/views/vrResourceDetail/info'),
		//			name: 'vrResourceInfo',
		//			hidden: true,
		//			meta: {
		//				title: '实验详情',
		//				icon: 'component',
		//				noCache: true,
		//			}
		//		}
	]
},
{
	path: '/courseware',
	component: Layout,
	redirect: '/courseware/coursewares',
	meta: {
		title: '课件管理',
		icon: 'list',
		noCache: true,
		flag: 'courseware:courseware'
	},
	children: [{
		path: 'coursewares',
		component: () =>
			import('@/views/courseware/index'),
		name: 'vrReportTemplates',
		meta: {
			title: '课件管理',
			icon: 'list',
			noCache: true,
			flag: 'courseware:coursewares'
		}
	}]
	},
{
	path: '/glbDetail',
	component: Layout,
	redirect: '/glbDetail/glbDetails',
	meta: {
		title: '模型管理',
		icon: 'list',
		noCache: true,
		flag: 'glbDetail:glbDetail'
	},
	children: [{
		path: 'glbDetail',
		component: () =>
			import('@/views/glbadmin/index'),
		name: 'glbDetails',
		meta: {
			title: '模型管理',
			icon: 'list',
			noCache: true,
			flag: 'glbDetail:glbDetails'
		},
	},]
	},

// 404 page must be placed at the end !!!
{
	path: '*',
	redirect: '/404',
	hidden: true
}
]

const createRouter = () => new Router({
	// mode: 'history', // require service support
	scrollBehavior: () => ({
		y: 0
	}),
	routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
	const newRouter = createRouter()
	router.matcher = newRouter.matcher // reset router
}

export default router